<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>分配角色</title>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctxAdmin}/sys/role/">角色列表</a></li>
		<li class="active"><a href="${ctxAdmin}/sys/role/assign?id=${role.id}"><shiro:hasPermission name="sys:role:edit">角色分配</shiro:hasPermission><shiro:lacksPermission name="sys:role:edit">人员列表</shiro:lacksPermission></a></li>
	</ul>
	<div class="container-fluid well">
		<div class="row">
			<span class="col-md-2">角色名称: <b>${role.name}</b></span>
			<span class="col-md-2">英文名称: ${role.code}</span>
			
			<span class="col-md-2">角色类型: ${role.roleType}</span>
			<c:set var="dictvalue" value="${role.dataScope}" scope="page" />
			<span class="col-md-2">数据范围: ${role.dataScopeValue}</span>
				
		</div>
	</div>
	<sys:message content="${message}"/>
	<div class="breadcrumb">
		<form id="assignRoleForm" action="${ctxAdmin}/sys/role/assignrole" method="post" class="hide">
			<input type="hidden" name="id" value="${role.id}"/>
			<input id="idsArr" type="hidden" name="idsArr" value=""/>
		</form>
		<div class="col-sm-12" style="text-align: right;padding-bottom: 3px;">
			<input id="assignButton" class="btn btn-primary" type="submit" value="分配角色"/>
		</div>
		<script type="text/javascript">
			$("#assignButton").click(function(){
				var height=$(top.document).height()-240;
				top.layer.open({
					id:'usertorole',
					title:'分配角色',
					type:2,
					shade:0.2,
					content:'${ctxAdmin}/sys/role/usertorole?id=${role.id}',
					area: ['810px', height+'px'],
					btn:['确定','清除','关闭'],
					yes:function(index,layero){
						
					},
					btn2:function(index,layero){
						top.layer.close(index);
					},
					btn3:function(index,layero){}
				})
			
			});
			function removeUser(user,role,href){
				layer.confirm('确认要将用户<b>['+user+']</b>从<b>['+role+']</b>角色中移除吗？',{title:'提示'},function(index){
					window.location.href=href;			  
					layer.close(index);
				});
			}
		</script>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
		<tr><th>归属部门</th><th>登录名</th><th>姓名</th><th>电话</th><th>手机</th>
		<shiro:hasPermission name="sys:user:edit"><th>操作</th></shiro:hasPermission>
		</tr>
		</thead>
		<tbody>
		<c:forEach items="${userList}" var="user">
			<tr>
				<td>${user.office.name}</td>
				<td><a href="${ctxAdmin}/sys/user/form?id=${user.id}">${user.loginName}</a></td>
				<td>${user.name}</td>
				<td>${user.phone}</td>
				<td>${user.mobile}</td>
				<shiro:hasPermission name="sys:role:edit"><td>
					<a href="javascript:void(0)" 
						onclick="removeUser('${user.name}','${role.name}','${ctxAdmin}/sys/role/outrole?userId=${user.id}&roleId=${role.id}')">移除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</body>
</html>
